﻿@{
    UserInfo user = ViewBag.User;
    if (user != null && user.Avatar.IsNullOrEmpty())
    {
        user.Avatar = Url.Content("~/_theme/default.jpg");
    }
    var qqUrl = UI.GetQQUrl();
    var wbUrl = UI.GetWbUrl();
    V_UserInformationStatistics userStatistics = ViewBag.UserInformationStatistics;
}
@using Infrastructure.DbModel
@using OAuth.Tools
@using SyntacticSugar
@using Infrastructure.ViewModels.BBS
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="icon" href="~/_theme/ico.ico" type="image/x-icon" />
    @RenderSection("meta",false)
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>@ViewBag.Title</title>
    <link rel="stylesheet" href="//at.alicdn.com/t/font_001z27klwvobt9.css">
    <link href="~/_theme/layui-v1.0.3/layui/css/layui.css?v=1" rel="stylesheet" />
    <link href="~/_theme/layui-v1.0.3/layui/css/global.css?v=1" rel="stylesheet" />
    @RenderSection("css", false)
    <link href="~/_theme/css/bbs.css?v=4" rel="stylesheet" />
</head>
<body>
    <input id="HidUrlAction" name="HidUrlAction" value="@Url.Action("/")" type="hidden" />
    <input id="HidUrlAction2" name="HidUrlAction" value="@Url.Content("/")" type="hidden" />
    <div class="header">
        <div class="main">
            <a class="logo" href="~/Ask" title="Fly">.NET 文档园</a>
            <div class="nav">
                <a href="~/">
                    <i class="iconfont icon-biaoqing" style="position:relative;top:2px"></i>
                    SqlSugar ORM
                </a>
                <a href="~/Doc/2" >
                    <i class="iconfont icon-daima" style="position:relative;top:2px"></i>
                    Asp.Net Core资料
                </a>
                <a href="~/Doc/3">
                    <i class="iconfont icon-shezhi"></i>
                    .NET工具类
                </a>
            </div>
            @if (ViewBag.IsLogin)
            {
                <div class="nav-user">
                    <a class="avatar" href="~/UserCenter">
                        <img src="@user.Avatar" />
                        <cite>@user.NickName</cite>
                        @if (userStatistics != null && userStatistics.PmsCount > 0)
                        {
                        <i class="pms-tip">(@userStatistics.PmsCount)</i>
                        }
                    </a>
                    <div class="nav">
                        <a href="@Url.Content("/Home/Logout")"><i class="iconfont icon-tuichu" style="top: 0; font-size: 22px;"></i>退了</a>
                    </div>
                </div>
            }
            else
            {
                <div class="nav-user">
                    <a class="unlogin" href="">
                        <i class="iconfont icon-touxiang"></i>
                    </a>
                    <span>
                        <a href="@Url.Content("/Home/Login")">登入</a>
                        <a href="@Url.Content("/Home/Register")">注册</a>
                    </span>
                    <p class="out-login">
                        <a href="@qqUrl" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" class="iconfont icon-qq" title="QQ登入"></a>
                        <a href="@wbUrl" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})" class="iconfont icon-weibo" title="微博登入"></a>
                    </p>
                </div>
            }
        </div>
    </div>
    <div class="main layui-clear">
        <div class="wrap">
            <div class="content">
                @RenderBody()
            </div>
        </div>
        @if (ViewBag.IsBBSMain == true)
        {
            List<UserInfo> newUserList = ViewBag.NewUserList;
            List<BBS_Forums> forList = ViewBag.ForList;
            Dictionary<int, string> forumsStatistics = ViewBag.ForumsStatistics;
            RightRelust rightData=ViewBag.BBS_Right;
            <div class="edge">
                <h3 class="page-title">版块</h3>
                <div class="user-looklog leifeng-rank ">
                    <span class="forums">
                        @if (forList != null)
                        {
                            var allPosts = 0;
                            foreach (var u in forList)
                            {
                                if (forumsStatistics.ContainsKey(u.Fid))
                                {
                                    u.Todayposts = forumsStatistics[u.Fid].TryToInt();
                                }
                                allPosts += u.Todayposts;
                                <a href="~/Ask/@(u.Fid)">
                                    <img src="~/_theme/img/forums/@(u.Fid).png">
                                    <i>@u.Name<label class="today">今天(<label class="today-num">@(u.Todayposts)</label>)</label> </i>
                                </a>
                            }
                            <a href="~/Ask">
                                <img src="~/_theme/img/forums/1.png">
                                <i>全部<label class="today">今天(<label class="today-num">@allPosts</label>)</label> </i>
                            </a>
                        }
                    </span>
                </div>

                <h3 class="page-title">学习文档</h3>
                <div class="user-looklog leifeng-rank">
                    <ul class="fly-list-one">
                        @if (rightData.DocMasterList.IsValuable())
                        {
                            foreach (var item in rightData.DocMasterList)
                            {
                                <li>
                                    <a href="~/@((item.Id==1).IIF("Home/Doc","Doc/"+item.Id))">
                                        @item.MasterName
                                    <i style="position:absolute;right:5px;color:#f60;font-style: initial;">最后更新:@item.LastPostDate.TryToDate().ToString("yyyy-MM-dd")</i>
                                </a>
                            </li>
                            }
                        }
                    </ul>
                </div>

                <h3 class="page-title">最新会员</h3>
                <div class="user-looklog leifeng-rank">
                    <span>
                        @if (newUserList != null)
                        {
                            foreach (var u in newUserList)
                            {
                                if (u.Avatar.IsNullOrEmpty())
                                {
                                    u.Avatar = Url.Content("~/_theme/default.jpg");
                                }
                                <a href="~/UserCenter/PublicInfo?id=@u.Id">
                                    <img src="@u.Avatar.Replace("/30","/100")">
                                    <cite>@u.NickName</cite>
                                    <i>@(u.CreateTime == null ? "" : SyntacticSugar.DateSugar.DateStringFromNow(u.CreateTime.TryToDate()))</i>
                                </a>
                            }
                        }
                    </span>
                </div>

                <h3 class="page-title">发布达人</h3>
                <div class="user-looklog leifeng-rank">
                    <span>
                        @if (rightData != null&&rightData.UserTopicsInfoList.IsValuable())
                        {
                            foreach (var u in rightData.UserTopicsInfoList)
                            {
                                if (u.Avatar.IsNullOrEmpty())
                                {
                                    u.Avatar = Url.Content("~/_theme/default.jpg");
                                }
                                <a href="~/UserCenter/PublicInfo?id=@u.Id">
                                    <img src="@u.Avatar.Replace("/30","/100")">
                                    <cite>@u.NickName</cite>
                                    <i>@u.TopicsCount 贴</i>
                                </a>
                            }
                        }
                    </span>
                </div>

                <h3 class="page-title">回贴达人</h3>
                <div class="user-looklog leifeng-rank">
                    <span>
                        @if (rightData != null&& rightData.UserRepliesList.IsValuable())
                        {
                            foreach (var u in rightData.UserRepliesList)
                            {
                                if (u.Avatar.IsNullOrEmpty())
                                {
                                    u.Avatar = Url.Content("~/_theme/default.jpg");
                                }
                                <a href="~/UserCenter/PublicInfo?id=@u.Id">
                                    <img src="@u.Avatar.Replace("/30","/100")">
                                    <cite>@u.NickName</cite>
                                    <i>@u.RepliesCount 贴</i>
                                </a>
                            }
                        }
                    </span>
                </div>

            </div>
        }
    </div>
    <div class="footer">
        <p>
            <a href="@Url.Content("/ask")">文档园</a>
            2016 &copy; <a href="@Url.Content("/")">CodeIsBug.com</a> <a href="https://github.com/sunkaixuan/" target="_blank">更多开源</a>
        </p>  <p>
            <a href="/" target="_blank">产品授权</a>
            <a href="/" target="_blank">VIP说明</a>
            <a href="/" target="_blank">商务合作</a>
            <a href="/" target="_blank" rel="nofollow">微博</a>
        </p>
    </div>
    <script src="~/_theme/layui-v1.0.3/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/_theme/layui-v1.0.3/layui/lay/modules/'
          , version: '11'
        }).use('global-bbs');
        window.global = {
            preview: function () {
                var preview = document.getElementById('LAY_preview');
                return preview ? preview.innerHTML : '';
            }()
        };
    </script>
    @RenderSection("js", false)
    <ul class="layui-fixbar">
        <li class="layui-icon layui-fixbar-top" lay-type="top" style=""></li>
    </ul>
</body>
</html>